print("Введите скобочную последовательность: ")
s = input()
s1 = ""
s2 = ""
s3 = ""
s4 = ""
s5 = ""
s6 = ""
s7 = ""
s8 = ""
for c in s :
    if c=='(' :
        s1+=c
    
    if c==')'and len(s3) == 0 and len(s1)>0:
        s2+=c
        if s1[-1] == '(':
            s1 = s1[:-1]
            s2 = s2[:-1]
        
    if c=='[':
        s3+=c
    
    if c==']' and len(s3)>0:
        s4+=c
        if s3[-1] == '[':
            s3 = s3[:-1]
            s4 = s4[:-1]
    
    if c=='{' :
        s5+=c
    
    if c=='}'and len(s7) == 0 and len(s5)>0:
        s6+=c
        if s5[-1] == '{':
            s5 = s5[:-1]
            s6 = s6[:-1]
        
    if c=='<':
        s7+=c
    
    if c=='>' and len(s7)>0:
        s8+=c
        if s7[-1] == '<':
            s7 = s7[:-1]
            s8 = s8[:-1]
        
if len(s1) == 0 and len(s2) == 0 and len(s3) == 0 and len(s4) == 0 and len(s5) == 0 and len(s6) == 0 and len(s7) == 0 and len(s8) == 0:
    print("True")
else:
    print("False")
